<template>
  <div class="partNewsIndex">
    <Aside></Aside>
    <Header :title="title" @toggleMenu="toggleMenu" @navToBack="navToBack">
    </Header>
      <div class="albumDetail">
        <div class="detailBanner">
          <img src="http://dangjian.co-links.com//Uploads/2018-07-17/5b4d8d99e5dd8.jpg" alt="">
          <div>
            <p class="p1">{{desc1}}</p>
            <p class="p2">{{desc2}}</p>
            <p class="p3">—  {{count}}张图片  —</p>
          </div>
        </div>
        <div class="albumDetailContent">
              <div v-for="(item,index) in albumDetailContent" >
                <img :src="item" onerror="this.onerror=null; this.src='../../static/images/codeCover2.jpg'">
              </div>
        </div>
      </div>
    <div class="albumScan">
      <div class="swiper-container" id="swiper-img">
        <div class="swiper-wrapper"></div>
        <div class="swiper-pagination"></div>
      </div>
    </div>

  </div>
</template>
<script >


  import aside from '../../components/aside.vue'
  import header from '../../components/header.vue'
  import {getQueryParam} from '@/utils/index.js'
  import {mapState} from 'vuex'
  export default({
    data (){
      return {
        nomoreData:false,
        loadmoreClick:false,
        title:'党建相册',
        desc1:'',
        desc2:'',
        count:0,
        resources:'',
        albumDetailContent:[

        ]
      }
    },
    components:{
      Aside:aside,
      Header:header
    },
      computed:{
        ...mapState({
          company_id:state=>state.app.company_id||getQueryParam('identifier',window.location.href).slice(0,getQueryParam('identifier',window.location.href).indexOf('/'))
        })
      },
    methods:{
      viewImage(){
//          console.log(123)
      },
      navToBack(){
        this.$router.go(-1);//返回上一层
      },
      toggleMenu(){
        $('.aside').toggleClass('active')
        $('body').toggleClass('active')
        if($('.aside').hasClass('active')){
          $('#toggleBtn').find('.img2').hide()
          $('#toggleBtn').find('.img1').show()
        }else{
          $('#toggleBtn').find('.img1').hide()
          $('#toggleBtn').find('.img2').show()
        }
      },
      loadMore (){
        this.loadmoreClick =!this.loadmoreClick
      },
      choiseHead(index){
        this.defaultIndex =index
      },
      init(){
//          console.log(this.$route.query.id)
          this.axios.get('/home/Photo/getPhotoDetail?'+`${this.baseUrl}`,{
              params:{
                  id:this.$route.query.id,
                  company_id:this.company_id
              }
          }).then((res)=>{
              this.albumDetailContent =res.data.data.data.path
              this.desc1 =res.data.data.data.name
              this.desc2 =res.data.data.data.content
              this.count =res.data.data.count
          })
            .then((res)=>{
              let that =this;
              var length =$('.albumDetailContent').children().length;
              var arr=[];
              var str ='';

              $('.albumDetailContent div img').each(function (index,item) {
                str ='<div class="swiper-slide"><img data-src="'+item.src+'" class="swiper-lazy"><div class="swiper-lazy-preloader"></div></div>';
                $('.swiper-wrapper').append(str)
                $(this).click(function () {
                  var index =$(this).parent().index()
                  $('.albumScan').show()
                  var swiper =new that.Swiper('#swiper-img',{
                    autoplay:false,
                    pagination: {
                      el: '.swiper-pagination',
                    },
                    lazy: {
                      loadPrevNext: true,
                    },
                    on:{
                      slideChangeTransitionEnd: function () { // pagination BUG
                        var activeIndex = this.activeIndex;
                        $('.swiper-pagination')
                          .find('span')
                          .eq(activeIndex)
                          .addClass('swiper-pagination-bullet-active')
                          .siblings()
                          .removeClass('swiper-pagination-bullet-active');
                      }
                    }
                  })
                  swiper.slideTo(index,0,false)
                  $('.albumScan').click(function () {
                    $(this).hide()
                    $('.swiper-notification').remove()
                  })
                })
              })
            })
      }
    },
    mounted (){
      $('body').removeClass('active')
      this.resources =this.$route.query.resources;
      console.log(this.resources)
    },
    created(){
        this.init()
    }

  })
</script>
<style scoped="">
  .detailBanner{
    margin-top: 0.8rem;
    height: 3.6rem;
    position: relative;
  }
  .detailBanner img{
    width: 100%;
    height: 3.6rem;
    -webkit-filter: blur(2px);
    -moz-filter: blur(2px);
    -o-filter: blur(2px);
    -ms-filter: blur(2px);
    filter: blur(2px);
  }
  .detailBanner div{
    position: absolute;
    left: 0;
    top:0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.2);
  }
  .detailBanner div .p1{
    padding: 0 0.32rem;
    font-size: 0.32rem;
    color: white;
    font-weight: bold;
    padding-top: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .detailBanner div .p2{
    padding: 0 0.32rem;
    font-size: 0.24rem;
    color: white;
    padding-top: 0.2rem;
    text-indent: 2em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
  }
  .detailBanner div .p3{
    position: absolute;
    left: 0;
    width: 100%;
    bottom: 0.26rem;
    color: white;
    font-size: 0.24rem;
    text-align: center;
  }
  .albumDetailContent{
    padding: 0 0.32rem;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .albumDetailContent div {
    width: 3.22rem;
    height: 2.06rem;
    margin-top: 0.3rem;
  }
  .albumDetailContent div img{
    display: inline-block;
    width: 3.22rem;
    height: 2.06rem;
    border-radius: 0.06rem;
    -webkit-border-radius: 0.06rem;
  }
  .albumScan{
    position: fixed;
    top:0;
    left:0;
    width: 100%;
    height: 100%;
    background: rgb(0,0,0);
    z-index: 989999;
    display: none;
  }
  .swiper-container{
    height: 200px;
    width: 100%;
    position: absolute;
    left:0;
    top:0;
    right: 0;
    bottom: 0;
    margin: auto;
  }
  .swiper-container .swiper-slide img{
    display: block;
    margin: 0 auto;
  }

  .swiper-pagination-bullet-active{
    opacity: 1;
    background: #e83329;
  }
</style>
